#!usr/bin/python3
import sys
import getopt
import os
import shutil


def getFilePathFromDir(path):
    """
    获取该目录下的所有文件完整路径，不递归
    :param path:
    :return:
    """

    L = 0
    for dirpath, dirnames, filenames in os.walk(path):
        for item in filenames:
            if item[0] == ".":
                continue
            item_split = os.path.splitext(item)
            music_content = item_split[0]  # 歌曲名和作者
            music_spix = item_split[1]  # 歌后缀
            split = music_content.split(" - ")
            changeFileName = dirpath + "/" + split[1] +" - "+ split[0] + music_spix
            orangeFileName = dirpath+"/"+item
            L = L + 1
            print("{}  {} --> {}".format(L,orangeFileName,changeFileName))
            shutil.move(orangeFileName, changeFileName)


if __name__ == '__main__':
    getFilePathFromDir("/Users/shu/Downloads/error")
    # getFilePathFromDir("/Users/shu/Downloads/tmp")
